
VStack is Container View which organizes his child Views vertically on top of each other.
You can't have empty VStack.
When adding Views to the Screen you can choose to
● insert into existing VStack
● insert into new VStack
Enclose existing View inside VStack (You can use this either in the Code or Automatic Preview)
Command + Click on the View + Embed in HStack
Syntax
VStack(alignment: .leading, spacing: 200)
Parameters
VStack(alignment: .leading)
Align child views to the left
VStack(alignment: .center)
Align child views to the right
VStack(alignment: .trailing)
Align child views to the right
Space between children. Instead of using Spacer()
In this example we create VStack with two Text Views and some Spacers between them.
Example
VStack {
Spacer()
Text("First Line")
Spacer()
Text("Second Line")
Spacer()
}
Output